package com.example.springdemo;

import com.example.springdemo.service.TestRetryService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;

@SpringBootApplication
@EnableScheduling
public class TestRetryApplication {

    @Resource
    private TestRetryService testRetryService;

    public static void main(String[] args) {
        SpringApplication.run(TestRetryApplication.class, args);
    }
//
//    @Bean
//    public CommandLineRunner commandLineRunner() {
//        return args -> {
//            System.out.println("开始测试异常重试机制...");
//
//            // 等待一段时间让应用完全启动
//            Thread.sleep(3000);
//
//            try {
//                System.out.println("调用测试方法，预期会抛出异常并保存到数据库...");
//                testRetryService.testRetryMethod("test-param-123");
//            } catch (Exception e) {
//                System.out.println("捕获到异常: " + e.getMessage());
//            }
//
//            System.out.println("测试完成，请检查数据库中的 biz_exception_retry_record 表是否有数据");
//        };
//    }
} 